﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace helloworld2.MODEL
{
    class PathFinder
    {
        Node cityStart;
        Node cityEnd;
        List<List<Node>> roadToGoal = new List<List<Node>>();
        double cost = 0;
        List<KeyValuePair<double, int>> roadCost = new List<KeyValuePair<double,int>>();
        List<Node> visited = new List<Node>();

        public PathFinder(Node cityStart, Node cityEnd)
        {
            this.cityStart = cityStart;
            cityStart.currentCost = 0;
            this.cityEnd = cityEnd;
            
            
            findPath(cityStart);
            
        }

        private void findPath(Node node)
        {

            List<Node> nodes = node.getConnection();
            int i;
            for (i = 0; i < node.getConnection().Count; i++)
            {
                Node n = nodes[i];
                n.currentCost = cost + n.currentCost;
            }

            for (i = 0; i < node.getConnection().Count; i++)
            {
                Node n = nodes[i];

                if (n.getConnection().Count < 2)
                {
                    findPath(nodes[i-1]);
                }


                findPath(n);
            }
            

            
        }


        }
    }
